<template>
    <div>
    <h3>新增医生信息</h3>
    <hr>
    <div class="title">医生信息</div>
    
  <div id="main">
    
    <el-form :inline="true" :model="ys" :rules="rules">
    <div class="top">
      <el-form-item label="医生编号:" >
      <el-input v-model="ys.id"  disabled/>
    </el-form-item>
    <el-form-item label="账号:"  prop="zh">
      <el-input v-model="ys.username" placeholder="请输入" />
    </el-form-item>
   <div class="imgs">
    <el-form-item label="医生图片:" >
      <el-upload
          class="avatar-uploader"
          action="http://quanzhan.site:5945/api/v1/admin/files"
          :headers="headers"
          :show-file-list="false"
          :on-success="handleAvatarSuccess"
          :before-upload="beforeAvatarUpload"
        >
          <img v-if="imageUrl" :src="imageUrl" class="avatar" />
          <el-icon v-else class="avatar-uploader-icon"><Plus /></el-icon>
        </el-upload>
    </el-form-item>
</div>
    <el-form-item label="医生姓名:" prop="xm">
      <el-input v-model="ys.name" placeholder="请输入" />
    </el-form-item>
    <div class="jues">
<span>医生角色:</span>
  <el-select v-model="options.label" placeholder="请选择" class="op" prop="js">
    <el-option
      v-for="item in options"
      :key="item.value"
      :label="item.label"
      :value="item.value"
    />
  </el-select>
</div>
    <el-form-item label="登录密码:" prop="mm">
      <el-input v-model="ys.password" placeholder="请输入" />
    </el-form-item>
    <div class="xb">
<span>性别:</span>
  <el-select v-model="optionss.label" placeholder="请选择" class="op">
    <el-option
      v-for="item in optionss"
      
      :key="item.value"
      :label="item.label"
      :value="item.value"
    />
  </el-select>
</div>
  </div>
<div class="btm">
    <el-form-item label="医生简介:" >
      <el-input v-model="ys.jianjie" placeholder="请输入"  type="textarea" class="as"/>
    </el-form-item>
    <el-form-item label="医生擅长:" >
      <el-input v-model="ys.long"  type="textarea" class="as" placeholder="请输入"/>
    </el-form-item>
  </div>
  </el-form>
</div>
<hr>
<div id="foot">
  <el-button type="primary" size="large">保存</el-button>
  <el-button type="primary" size="large">返回</el-button>
</div>

</div>
    
</template>
<script>
import { ElMessage } from 'element-plus'
import { Plus } from '@element-plus/icons-vue'
export default {
  components: {
    Plus,
  },
    data() {
        return {
            ys:{
                id:'001',
                username:'',
                img:'',
                name:'',
                password:'',
                jianjie:'',
                long:'',
            },
            imageUrl: '',
            rules:{
              zh:[
                {required:true}
              ],
              js:[
                {required:true}
              ],
              mm:[
                {required:true}
              ],
              xm:[
                {required:true}
              ],
            },
            options:[
  {
    value: 'Option2',
    label: '系统管理员',
  },
  {
    value: 'Option3',
    label: '全科医师',
  },
  {
    value: 'Option4',
    label: '全科护士',
  },
  {
    value: 'Option5',
    label: '护理医师',
  },
    ],
    optionss:[
  {
    value: 'Option2',
    label: '男',
  },
  {
    value: 'Option3',
    label: '女',
  },
    ],
        }
    },
    computed:{
    headers(){
      return{
        Authorization:'Bearer '+this.$store.getters.token
      }
    }
  },
    methods: {
      beforeAvatarUpload (rawFile){
      if (rawFile.type !== 'image/jpeg') { // 格式
        ElMessage.error('只能上传jpg格式的图片!')
        return false
      }
      if (rawFile.size / 1024 / 1024 > 2) { // 大小
        ElMessage.error('文件大小不能超过2MB!')
        return false
      }
      return true
    },

    /**
     * 文件上传成功
     */
     handleAvatarSuccess(response, uploadFile) {
      console.log('response:', response)
      this.user.avatarUrl = response.data.file
      this.imageUrl = URL.createObjectURL(uploadFile.raw)
    }
    },
}
</script>
<style>
.title{
    width: 80px;
    height: 20px;
  
    position: relative;
    left: 0px;
    top: 0px;
}
#main{
  width: 1000px;
  height: 600px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-content: center;
}

#main .top{
    font-size: 16px;
  width: 1000px;
  height: 300px;
  flex-wrap: wrap;
  display: flex;
  justify-content:space-around;
  align-items: center;
}
.top input{
    width: 150px;
}
.top .xb{
   position: relative;
   top: 0px;
   left: -323px;
    display: flex;
  justify-self: flex-start;
  align-items: center;
}
.xb span{
   position: relative;
   top: 0px;
   left: -14px;
    font-size: 16px;
    color: #8c939d;
}
.top .jues{
    position: relative;
   top: -8px;
   left: -55px;
}
.jues span{
   position: relative;
   top: 0px;
   left: 0px;
    font-size: 16px;
    color: #8c939d;
}
.op{
    width: 180px;
}
.imgs{
  display: flex;
  justify-content: center;
  align-items: center;
  margin-left: 150px;
  vertical-align:center;
}
#main .btm{
  width: 1000px;
  height: 200px;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  align-items: flex-start;
}
#main .btm input{
  width: 300px;
}
#main .as{
  width: 320px;
}
#foot{
  width: 100%;
  height: 50px;
  display: flex;
  justify-content: flex-start;
  align-items: center;
}
.avatar-uploader .avatar {
  width: 50px;
  height: 50px;
  display: block;
}

.avatar-uploader .el-upload {
  border: 1px dashed var(--el-border-color);
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: var(--el-transition-duration-fast);
}

.avatar-uploader .el-upload:hover {
  border-color: var(--el-color-primary);
}

.el-icon.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 100px;
  height: 100px;
  text-align: center;
}

</style>